/*********************************************************************NVMH3****
/ fragment shader for blending lightmaps 
******************************************************************************/
// get the two lightmaps and blend them together

uniform sampler2D Original;
uniform sampler2D LightMap;
varying vec4  texcoord[2];

uniform vec4 blendAmount;

void main(void)
{
    // sample color from a texture
    vec4 base_color  = texture2D(Original,  vec2(texcoord[0]));
    vec4 light_color = texture2D(LightMap,  vec2(texcoord[1]));
    
    // calculate the new color
   float shadeColor = 0.0;
  
    shadeColor += (light_color.r ) * blendAmount.r;
    shadeColor += (light_color.g) * blendAmount.g;
    shadeColor += (light_color.b ) * blendAmount.b;
    
    shadeColor = (shadeColor / 3.0);
      
    // add shade
    base_color = base_color * shadeColor;
//    base_color.r = blendAmount.r;
//    base_color.g = blendAmount.g;
//   base_color.b = blendAmount.b;

    gl_FragColor = base_color;

}
